<?php

class IndexController extends Plugin {

    public function __construct() {
        parent::__construct();
    }
    
    public function listAction() {
	    $page = (int)$this->get('page');
	    $page = $page ? $page : 1;
	    $cid  = $this->get('cid') ? $this->get('cid') : 0;
		$this->view->assign(array(
			'cid'  => $cid,
		    'page' => $page,
		));
		$this->view->display(substr($this->setting['listtpl'], 0, -5));
    }
	
	public function showAction() {
	    $id   = $this->get('id');
		$id   = $id ? $id : $this->get('iid');
	    $page = (int)$this->get('page');
	    $page = $page ? $page : 1;
		$data = get_taobao_item($id);
		if (empty($data)) $this->msg('没有获取到商品信息', 0, 1);
		if (isset($data['location'])) $data['location'] = @implode(' - ', $data['location']);
		$this->view->assign($data);
	    $this->view->assign(array(
			'id'   => $id,
		    'page' => $page,
		));
		$this->view->display(substr($this->setting['showtpl'], 0, -5));
	}
    
}